package codejam.africa2010;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

/**
 * Problem
 * 
 * You are hosting a party with G guests and notice that there is an odd number
 * of guests! When planning the party you deliberately invited only couples and
 * gave each couple a unique number C on their invitation. You would like to
 * single out whoever came alone by asking all of the guests for their
 * invitation numbers.
 * 
 * Input
 * 
 * The first line of input gives the number of cases, N. N test cases follow.
 * For each test case there will be:
 * 
 * One line containing the value G the number of guests. One line containing a
 * space-separated list of G integers. Each integer C indicates the invitation
 * code of a guest. Output
 * 
 * For each test case, output one line containing "Case #x: " followed by the
 * number C of the guest who is alone.
 * 
 * Limits
 * 
 * 1 ≤ N ≤ 50 0 < C ≤ 2147483647 Small dataset
 * 
 * 3 ≤ G < 100 Large dataset
 * 
 * 3 ≤ G < 1000 Sample
 * 
 * 
 * Input
 * 
 * Output 3 3 1 2147483647 2147483647 5 3 4 7 4 3 5 2 10 2 10 5 Case #1: 1 Case
 * #2: 7 Case #3: 5
 * 
 * http://code.google.com/codejam/contest/dashboard?c=438101#s=p0
 * 
 * @author coddy
 * 
 */
public class OldManOut
{

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		try
		{
			BufferedReader bf = new BufferedReader(new FileReader(
					"A-large-practice.in"));
			BufferedWriter bw = new BufferedWriter(new FileWriter(
					"A-large-practice.out"));
			int n = Integer.parseInt(bf.readLine());
			for (int i = 1; i <= n; i++)
			{
				int k = Integer.parseInt(bf.readLine());

				Set set = new TreeSet();
				String line = bf.readLine();

				StringTokenizer tokenizer = new StringTokenizer(line);
				while (tokenizer.hasMoreElements())
				{
					String string = (String) tokenizer.nextElement();
					int number = Integer.parseInt(string);
					if (set.contains(number))
					{
						set.remove(number);
					} else
					{
						set.add(number);
					}
				}

				bw.write("Case #" + i + ": " + set.toArray()[0]);
				bw.write("\n");

			}
			bw.flush();

		} catch (FileNotFoundException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NumberFormatException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
